﻿using System;
using System.Runtime.InteropServices;
using System.Security;

namespace ToolSharp.Windows.Native
{
	[StructLayout(LayoutKind.Sequential)]
	public struct COORD
	{
		public short X;
		public short Y;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct DynamicTimeZoneInformation
	{
		[MarshalAs(UnmanagedType.I4)]
		public int Bias;
		[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
		public string StandardName;
		public SystemTime StandardDate;
		[MarshalAs(UnmanagedType.I4)]
		public int StandardBias;
		[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
		public string DaylightName;
		public SystemTime DaylightDate;
		[MarshalAs(UnmanagedType.I4)]
		public int DaylightBias;
		[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x80)]
		public string TimeZoneKeyName;
		[MarshalAs(UnmanagedType.Bool)]
		public bool DynamicDaylightTimeDisabled;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct CHAR_INFO
	{
		private ushort charData;
		private short attributes;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct CONSOLE_CURSOR_INFO
	{
		public int dwSize;
		public bool bVisible;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct CONSOLE_SCREEN_BUFFER_INFO
	{
		public COORD dwSize;
		public COORD dwCursorPosition;
		public short wAttributes;
		public SMALL_RECT srWindow;
		public COORD dwMaximumWindowSize;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct FILE_TIME
	{
		public uint ftTimeLow;
		public uint ftTimeHigh;
		public FILE_TIME(long fileTime)
		{
			throw new NotImplementedException();
		}
		public long ToTicks()
		{
			throw new NotImplementedException();
		}
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
	public struct InputRecord
	{
		public short eventType;
		public KeyEventRecord keyEvent;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
	public struct KeyEventRecord
	{
		public bool keyDown;
		public short repeatCount;
		public short virtualKeyCode;
		public short virtualScanCode;
		public char uChar;
		public int controlKeyState;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct LSA_OBJECT_ATTRIBUTES
	{
		public int Length;
		public IntPtr RootDirectory;
		public IntPtr ObjectName;
		public int Attributes;
		public IntPtr SecurityDescriptor;
		public IntPtr SecurityQualityOfService;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct LSA_REFERENCED_DOMAIN_LIST
	{
		public int Entries;
		public IntPtr Domains;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct LSA_TRANSLATED_SID
	{
		public int Use;
		public uint Rid;
		public int DomainIndex;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct LSA_TRANSLATED_SID2
	{
		public int Use;
		public IntPtr Sid;
		public int DomainIndex;
		private uint Flags;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct LUID
	{
		public uint LowPart;
		public uint HighPart;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct LUID_AND_ATTRIBUTES
	{
		public LUID Luid;
		public uint Attributes;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct QUOTA_LIMITS
	{
		public IntPtr PagedPoolLimit;
		public IntPtr NonPagedPoolLimit;
		public IntPtr MinimumWorkingSetSize;
		public IntPtr MaximumWorkingSetSize;
		public IntPtr PagefileLimit;
		public IntPtr TimeLimit;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct RegistryTimeZoneInformation
	{
		[MarshalAs(UnmanagedType.I4)]
		public int Bias;
		[MarshalAs(UnmanagedType.I4)]
		public int StandardBias;
		[MarshalAs(UnmanagedType.I4)]
		public int DaylightBias;
		public SystemTime StandardDate;
		public SystemTime DaylightDate;
		public RegistryTimeZoneInformation(TimeZoneInformation tzi)
		{
			throw new NotImplementedException();
		}
		public RegistryTimeZoneInformation(byte[] bytes)
		{
			throw new NotImplementedException();
		}
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct SID_AND_ATTRIBUTES
	{
		public IntPtr Sid;
		public uint Attributes;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct SMALL_RECT
	{
		public short Left;
		public short Top;
		public short Right;
		public short Bottom;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct SYSTEM_INFO
	{
		public int dwOemId;
		public int dwPageSize;
		public IntPtr lpMinimumApplicationAddress;
		public IntPtr lpMaximumApplicationAddress;
		public IntPtr dwActiveProcessorMask;
		public int dwNumberOfProcessors;
		public int dwProcessorType;
		public int dwAllocationGranularity;
		public short wProcessorLevel;
		public short wProcessorRevision;
	}

	[StructLayout(LayoutKind.Sequential)]
	public struct SystemTime
	{
		[MarshalAs(UnmanagedType.U2)]
		public short Year;
		[MarshalAs(UnmanagedType.U2)]
		public short Month;
		[MarshalAs(UnmanagedType.U2)]
		public short DayOfWeek;
		[MarshalAs(UnmanagedType.U2)]
		public short Day;
		[MarshalAs(UnmanagedType.U2)]
		public short Hour;
		[MarshalAs(UnmanagedType.U2)]
		public short Minute;
		[MarshalAs(UnmanagedType.U2)]
		public short Second;
		[MarshalAs(UnmanagedType.U2)]
		public short Milliseconds;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct TimeZoneInformation
	{
		[MarshalAs(UnmanagedType.I4)]
		public int Bias;
		[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
		public string StandardName;
		public SystemTime StandardDate;
		[MarshalAs(UnmanagedType.I4)]
		public int StandardBias;
		[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
		public string DaylightName;
		public SystemTime DaylightDate;
		[MarshalAs(UnmanagedType.I4)]
		public int DaylightBias;
		public TimeZoneInformation(DynamicTimeZoneInformation dtzi)
		{
			throw new NotImplementedException();
		}
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct TOKEN_GROUPS
	{
		public uint GroupCount;
		public SID_AND_ATTRIBUTES Groups;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct TOKEN_PRIVILEGE
	{
		public uint PrivilegeCount;
		public LUID_AND_ATTRIBUTES Privilege;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct TOKEN_SOURCE
	{
		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
		public char[] Name;
		public LUID SourceIdentifier;
		private const int TOKEN_SOURCE_LENGTH = 8;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct TOKEN_STATISTICS
	{
		public LUID TokenId;
		public LUID AuthenticationId;
		public long ExpirationTime;
		public uint TokenType;
		public uint ImpersonationLevel;
		public uint DynamicCharged;
		public uint DynamicAvailable;
		public uint GroupCount;
		public uint PrivilegeCount;
		public LUID ModifiedId;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct TOKEN_USER
	{
		public SID_AND_ATTRIBUTES User;
	}

	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	public struct UNICODE_STRING
	{
		public ushort Length;
		public ushort MaximumLength;
		[MarshalAs(UnmanagedType.LPWStr)]
		public string Buffer;
	}
}
